package com.zzl.bonds.ticket.conf;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * Rabbit 配置文件
 * executeWaitingPayment
 *
 * @author hyt
 * @date 2021/7/15
 */
@Configuration
public class RabbitMqConf {
    /**
     * |兑付 回告的 交换机 和 key
     */
    public static final String SYSTEM_EXCHANGE = "systemExchange";

    public static final String TASK_CALLBACK = "taskCallback";
    /**
     * 预兑付任务 key
     */
    public static final String ADVANCE_PAYMENT_KEY = "advancePayment";


    /**
     * 处理授信状态的 key
     */
    public static final String CREDIT_STATUS = "creditStatus";

    /**
     * 预兑付任务 交换机
     */
    public static final String ADVANCE_PAYMENT_EXCHANGE = "advancePaymentExchange";

    /**
     * 预兑付任务 队列
     */
    public static final String ADVANCE_PAYMENT_QUEUE = "advancePaymentQueue";

    /**
     * 处理授信状态的任务 队列
     */
    public static final String CREDIT_STATUS_QUEUE = "creditStatusQueue";


    @Bean
    public Queue creditStatusQueue() {
        return new Queue(CREDIT_STATUS_QUEUE, true);
    }


    @Bean
    public Queue advancePaymentQueue() {
        return new Queue(ADVANCE_PAYMENT_QUEUE, true);
    }

    @Bean
    public DirectExchange advancePaymentExchange() {
        return new DirectExchange(ADVANCE_PAYMENT_EXCHANGE, true, false);
    }


    @Bean
    Binding bind1() {
        return BindingBuilder.bind(advancePaymentQueue()).to(advancePaymentExchange()).with(ADVANCE_PAYMENT_KEY);
    }

    @Bean
    Binding bind2() {
        return BindingBuilder.bind(creditStatusQueue()).to(advancePaymentExchange()).with(CREDIT_STATUS);
    }


}
